/**
 * Filename: AlbumIntroFragment.java
 *
 * @author Firefly
 * @contact postfirefly@163.com
 * @time 2016/3/15 14:35
 */
package com.github.postsanf.yinian.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.postsanf.yinian.BaseFragment;
import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.adapter.AlbumIntroAdapter;
import com.github.postsanf.yinian.bean.YNAlbum;
import com.github.postsanf.yinian.constants.YNSingleton;
import com.github.postsanf.yinian.utils.WrapContentLinearLayoutManager;
import com.umeng.analytics.MobclickAgent;

/**
 * 官方相册介绍
 */
public class AlbumIntroFragment extends BaseFragment {
    private View view;
    private YNAlbum curAlbum;
    private RecyclerView mRecyclerView;
    private AlbumIntroAdapter mIntroAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        initView();
        return view;
    }

    private void initView() {
        curAlbum = YNSingleton.getInstance().getCurAlbum();
        view = View.inflate(getActivity(), R.layout.yn_frag_intro, null);
        mRecyclerView = (RecyclerView) view.findViewById(R.id.rv_album_intro);
        WrapContentLinearLayoutManager mLinearLayout = new WrapContentLinearLayoutManager(getActivity());
        mLinearLayout.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(mLinearLayout);
        mIntroAdapter = new AlbumIntroAdapter(getActivity(), curAlbum.getGintroducePic(), curAlbum.getGintroduceText());
        mRecyclerView.setAdapter(mIntroAdapter);
        mRecyclerView.setHasFixedSize(true);
    }

    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("MainScreen");
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("MainScreen");
    }
}